package com.wu.llpsw.effect.buff;


import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.effect.MobEffectCategory;
import com.wu.llpsw.yuanli.energy.yuanliManager;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;

import java.util.Random;

//元力絮乱buff
public class yuanlixuluan extends BaseEffect{
    public yuanlixuluan(MobEffectCategory type, int color, boolean isInstant) {
        super(type, color, isInstant);
    }


    //buff隔多久生效一次
    @Override
    protected boolean canApplyEffect(int remainingTicks, int level) {
        return remainingTicks % 5 == 0;
    }

    //效果作用用于身上的效果
    @Override
    public void applyEffectTick(LivingEntity entity, int value) {
        if(entity instanceof ServerPlayer){
            Player player=(Player) entity;
            Random random=new Random();
            int x=random.nextInt(19)-10;
            yuanliManager.use(player,x);
        }
    }


    //申明是debuff还是buff
    @Override
    public boolean isBeneficial() {
        return true;
    }
}
